<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    
	
	<title>_${customer.customerName}_入库信息</title>
	<script type="text/javascript">
	
        $(function() {
		    $("#queryForm").validate(); 
			$("#_fromDate").datepicker({ format : 'yyyy-mm-dd' });
			$("#_toDate").datepicker({ format : 'yyyy-mm-dd' });
			var now = new Date();
			var tomorrow = new Date();
			tomorrow.setDate(now.getDate()+1);
			if(!$("#_fromDate").val()){
				$("#_fromDate").val(now.Format("yyyy-MM-dd"));
			}
			if($("#_toDate").val() == ''){
				$("#_toDate").val(tomorrow.Format("yyyy-MM-dd"));
			}
       });
       
	  
  //显示入库信息详情
  function showDetail(sku){
      $("#_sku_hidden").val(sku);
      $("#detailQueryForm").submit();
    }
    
    function detailSubmit(){
        $("#_fromDate_hidden").val( $("#_fromDate").val() );
        $("#_toDate_hidden").val( $("#_toDate").val() );
        $("#_customerCode_hidden").val( $("#_customerCode").val() );
        $("#_warehouseCode_hidden").val( $("#_warehouseCode").val() );
        $("#_billCode_hidden").val( $("#_billCode").val() );
        $("#_sku_hidden").val( $("#_sku").val() );
        
        $("#detailQueryForm").submit();
    }
    
    function querySubmit(){
    	$("#queryForm").attr("action","${ctx}/instorageInfo/v2_queryInstorageInfo");
        $("#queryForm").submit();
    }
	
	function exportExcel(){
			$("#queryForm").attr("action","${ctx}/instorageInfo/exportExcel");
	        $("#queryForm").submit();
	        
      }
    </script>
</head>

<body>
<section class="content">
	<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-search"></i>
					<h3 class="box-title">搜索栏</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
	<form class="form-search" id="queryForm" action="${ctx}/instorageInfo/v2_queryInstorageInfo" method="post">
		<div class="form-group row">
			<div class="col-sm-3">
				<div class="input-group col-sm-12">
			    <label class="input-group-text">商家名称：</label>
				 <select  name="_customerCode"  id="_customerCode" value="${_customerCode}"  class="form-control" onchange="ajaxAreaGroup(this,'_warehouseCode');">
					<option value=""></option>
					<c:forEach items="${customerList}" var="customer">
						<option value="${customer.customerCode}"
						<c:if test="${_customerCode eq customer.customerCode}">selected=selected</c:if>
						>${customer.customerName}</option>
					</c:forEach>
				</select>
				</div>
				</div>
				
				<div class="col-sm-3">
				<div class="input-group col-sm-12">
				<label class="input-group-text">仓库名称：</label>
				<select  name="_warehouseCode"  id="_warehouseCode" value="${_warehouseCode}"  class="form-control required">
					<option value=""></option>
					<c:forEach items="${warehouseList}" var="wm">
						<option value="${wm.groupCode}"
						<c:if test="${_warehouseCode eq wm.groupCode}">selected=selected</c:if>
						>${wm.groupName}</option>
					</c:forEach>
				</select>
				</div>
				</div>
				
				<div class="col-sm-3">
				<div class="input-group col-sm-12">
				<label class="input-group-text">入库日期：</label> 
			 	<input type="text" name="_fromDate" id="_fromDate"  class="form-control required" value="${_fromDate}"/>
			 	</div>
			 	</div>
			 	
			 	<div class="col-sm-3">
				<div class="input-group col-sm-12">
			 	<label class="input-group-text">至：</label> 
			 	<input type="text" name="_toDate" id="_toDate" class="form-control required" value="${_toDate}" />
			 	</div>
			 	</div>
			 	</div>
			 	
				
			<div class="form-group row">
				<div class="col-sm-3">
				<div class="input-group col-sm-12">
				<label class="input-group-text">入库单号：</label> 
				<input  name="_billCode"  id="_billCode" value="${_billCode}"  class="form-control" />
				</div>
				</div>
				
				<div class="col-sm-3">
				<div class="input-group col-sm-12">
				<label class="input-group-text">SKU编号：</label> 
				<input  name="_sku"  id="_sku" value="${_sku}" class="form-control" />
			 	</div>
			 	</div>
			 	
			 	<div class="col-sm-3">
				<div class="input-group col-sm-12">
			    <button type="button" class="btn btn-info" style="margin-left: 10px;" onclick="querySubmit();">查询</button>
			    <button type="button" class="btn btn-primary" style="margin-left: 10px;"  onclick="detailSubmit();" >入库明细</button>
			    <a class="btn btn-primary" type="button" onclick="exportExcel()">导出Excel</a>
			    </div>
			    </div>
			</div>
	 </form>
	
	<form class="form-search" id="detailQueryForm" action="${ctx}/instorageInfo/v2_toDetailInfo" method="post">
	     <input type="hidden" name="_customerCode_hidden" id="_customerCode_hidden"  value="${_customerCode}">
	     <input type="hidden" name="_warehouseCode_hidden" id="_warehouseCode_hidden" value="${_warehouseCode}">
	     <input type="hidden" name="_billCode_hidden" id="_billCode_hidden" value="${_billCode}">
	     <input type="hidden" name="_fromDate_hidden" id="_fromDate_hidden" value="${_fromDate}"> 
	     <input type="hidden" name="_toDate_hidden" id="_toDate_hidden" value="${_toDate}">
	     <input type="hidden" name="_sku_hidden" id="_sku_hidden" value="${_sku}">
	</form>
	</div>
	</div>
	</div>
	</div>
	
	
	<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-list"></i>
					<h3 class="box-title">查询结果</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead><tr>
		    <th style="width: 80px;">序列</th>
		    <th style="width: 80px;">商家</th>
		    <th style="width: 80px;">仓库</th>
		    <th>SKU</th>
		    <th>商品名</th>
		    <th>采购入库</th>
		    <th>调拨入库</th>
		    <th>退回入库</th>
			<th>入库合计</th>
			<th style="width: 80px;">操作</th>
		</tr></thead>
		<tbody>
		
		<c:if test="${empty dtoList or dtoList.size() eq 0}">
	       <tr><td colspan="10" height="50" style="vertical-align:middle; text-align: center;color: gray;font-size: 20px;">无数据</td></tr>
	    </c:if>
		
		<c:if test="${not empty dtoList}">
		<c:forEach items="${dtoList}" var="dto" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			   <td>
			  	<c:forEach items="${customerList}" var="customer">
					<c:if test="${dto.customerCode eq customer.customerCode}">${customer.customerName}</c:if>
				</c:forEach>
			   </td>
			   <td>
			   <c:forEach items="${warehouseList}" var="wm">
					<c:if test="${dto.warehouseCode eq wm.groupCode}">${wm.groupName}</c:if>
				</c:forEach>
			   </td>
			   <td>${dto.sku}</td>
			   <td>${dto.skuName}</td>
			   <td>${dto.customerNum}</td>
			   <td>${dto.allotNum}</td>
			   <td>${dto.returnNum}</td>
			   <td>${dto.totalNum}</td>
			   <td>
				  <a href="#detail" data-toggle="modal" class="btn btn-info" onclick="showDetail('${dto.sku}');" >明细</a>
			   </td>
			</tr>
		</c:forEach>
		</c:if>
		
		</tbody>
	</table>
	</div>
	</div>
	</div>
	</div>
	
	
</section>	
</body>
</html>
